package jDev.SimEngine.Implementation.Scanner;

import jDev.SimEngine.Tools.JDEV_LOG;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class CorporationScannerImpl implements
		jDev.SimEngine.Interfaces.Scanner.ICorporationScanner {

	HashMap<Integer,String> corporationList;
	BufferedReader bis;
	InputStream is;

	public CorporationScannerImpl() {

		corporationList = new HashMap<Integer,String>();
		bis = new BufferedReader(new InputStreamReader(getClass()
				.getResourceAsStream("Corporations/List.txt")));

	}

	@Override
	public void scanCorpList() {
		try {
			String s;
			while (null != (s = bis.readLine())) {
				StringTokenizer s2 = new StringTokenizer(s, ";", false);
				while(s2.hasMoreTokens()) {
					corporationList.put(Integer.valueOf(s2.nextToken()), s2.nextToken());
				}
			}
		} catch (IOException e) {

			e.printStackTrace();
		}
		JDEV_LOG.printMSG("Corporations loaded " + corporationList);

	}

	@Override
	public String getCorporation(int id) {
		String corporations = corporationList.get(id);
		return corporations;
	}

	@Override
	public HashMap<Integer, String> getCorporationList() {
		
		return corporationList;
	}

}
